package com.dk.service.impl;

import com.dk.mapper.TabUserMapper;
import com.dk.pojo.TabUser;
import com.dk.service.CustomerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    TabUserMapper tabUserMapper;

    @Override
    public PageInfo<TabUser> getInfo(TabUser tabUser,Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<TabUser> tabUsers = tabUserMapper.getInfo(tabUser);
        PageInfo<TabUser> pageInfo  = new PageInfo<>(tabUsers);
        return pageInfo;
    }

    @Override
    public int insertInfo(TabUser user) {
        return tabUserMapper.insertSelective(user);
    }

    @Override
    public TabUser getInfoById(Integer id) {
        return tabUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteInfoByUid(Integer uid) {
        return tabUserMapper.deleteByPrimaryKey(uid);
    }

    @Override
    public int updateCustomer(TabUser tabUser) {
        return tabUserMapper.updateByPrimaryKeySelective(tabUser);
    }
}
